//
//  TKIMFileHelper.h
//  TKIM
//
//  Created by liupm on 15/10/23.
//  Copyright © 2015年 liupm. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKIT/UIKit.h>

@interface TKIMFileHelper : NSObject


/**
 *  @Author lpm, 15-11-02 14:11:10
 *
 *  @brief  文件是否存在
 *
 *  @param fileUrl
 *
 *  @return
 */
+(BOOL)fileIsExist:(NSString *)fileUrl;

/**
 *  @Author lpm, 15-11-02 14:11:10
 *
 *  @brief  文件是否存在
 *
 *  @param fileUrl
 *
 *  @return
 */
+(BOOL)fileIsExist:(NSString *)fileUrl fileSize:(long long)fileSize;


/**
 *  @Author lpm, 15-11-03 17:11:12
 *
 *  @brief  沙盒路径
 *
 *  @return
 */
+(NSString *)documentDirectorySubpath:(NSString *)subpath;



/**
 *  @Author lpm, 15-11-03 17:11:29
 *
 *  @brief  创建目录
 *
 *  @param dirUrl
 */
+(BOOL)creatDir:(NSString *)dirUrl;


/**
 *  @Author lpm, 15-11-03 17:11:08
 *
 *  @brief  将原始图片的URL转化为NSData数据,写入沙盒
 *
 *  @param url
 *  @param fileName
 *  @param complete
 */
+ (void)saveImageWithUrl:(NSURL *)url withFileName:(NSString *)fileName complete:(void(^)(NSString *imagePath,NSError *error))complete;


/**
 *  @Author lpm, 15-11-03 17:11:53
 *
 *  @brief  将原始视频的URL转化为NSData数据,写入沙盒
 *
 *  @param url
 *  @param fileName
 *  @param complete
 */
+ (void)saveVideoWithUrl:(NSURL *)url withFileName:(NSString *)fileName complete:(void(^)(NSString *videoPath,NSError *error))complete;



/**
 *  @Author lpm, 15-11-10 11:11:27
 *
 *  @brief  创建文件
 *
 *  @param fileUrl
 *  @param data
 *
 *  @return
 */
+(BOOL)creatFile:(NSString *)fileUrl data:(NSData *)data;


/**
 *  @Author lpm, 15-10-23 16:10:17
 *
 *  @brief  获取网络文件大小
 *
 *  @param url
 *
 *  @return
 */
+(long long)fileSizeWithURL:(NSURL *)url;


/**
 *  @Author lpm, 15-10-23 16:10:17
 *
 *  @brief  获取网络文件大小
 *
 *  @param url
 *
 *  @return
 */
+(void)fileSizeWithURL:(NSURL *)url callBack:(void(^)(long long size))callBack;


/**
 *  @Author lpm, 15-10-23 16:10:29
 *
 *  @brief  读取本地缓存文件大小
 *
 *  @return
 */
+(long long)localFileSize:(NSString *)url;


/**
 *  @Author lpm, 15-11-12 10:11:23
 *
 *  @brief  规范文件单位
 *
 *  @param bytesize
 *
 *  @return
 */
+(NSString *)sizeformat:(CGFloat )bytesize;



/**
 * @Author lpm, 15-01-09 20:01:08
 *
 * 移动文件
 * @param dbname
 * @return
 */
+(NSString *)moveFile:(NSString *)fileUrl fileName:(NSString *)fileName;



/**
 *  @Author lpm, 15-11-04 09:11:23
 *
 *  @brief  将文件转换成mp4格式
 *
 *  @param movUrl
 *
 *  @return
 */
+ (void)convert2Mp4:(NSURL *)movUrl complete:(void(^)(NSURL *mp4Url))complete;


/**
 * @Author 刘鹏民, 15-01-09 20:01:08
 *
 * 拷贝文件
 * @param dbname
 * @return
 */
+(BOOL)copyFile:(NSString *)filePath to:(NSString *)writePath;


/**
 *  @Author lpm, 16-04-15 14:04:12
 *
 *  @brief  取消备份
 *
 *  @param URL
 *
 *  @return
 */
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;



/**
 *  @Author lpm, 17-05-22 16:05:28
 *
 *  @brief  删除文件
 *
 *  @param fileUrl
 */
+(void)removeFile:(NSString *)fileUrl;

@end



